home *** CD-ROM | disk | FTP | other *** search
/ ftp.cs.arizona.edu / ftp.cs.arizona.edu.tar / ftp.cs.arizona.edu / icon / newsgrp / group97a.txt / 000135_icon-group-sender _Wed Jun 11 11:16:51 1997.msg < prev    next >
Internet Message Format  |  2000-09-20  |  2KB

  1. Received: from kingfisher.CS.Arizona.EDU by cheltenham.cs.arizona.edu; Wed, 11 Jun 1997 12:25:58 MST
  2. Received: by kingfisher.CS.Arizona.EDU; (5.65v3.2/1.1.8.2/08Nov94-0446PM)
  3.     id AA08982; Wed, 11 Jun 1997 12:25:57 -0700
  4. Date: Wed, 11 Jun 1997 11:16:51 -0700
  5. From: swampler@noao.edu (Steve Wampler)
  6. Subject: Re: searching with variables
  7. To: icon-group@cs.arizona.edu
  8. Message-Id: <swampler-9705111816.AA004014681@orpheus.gemini.edu>
  9. Errors-To: icon-group-errors@cs.arizona.edu
  10. Status: RO
  11. Content-Length: 1132
  12.  
  13.  
  14.  
  15. - Forwarded message from espie@felouque.ens.fr on 11 Jun 1997 16:17:05 GMT -
  16. > In general, icon pattern matching is not too great at stupid regular 
  17. > expression emulation.  They're much better at building intricate mechanisms 
  18. > that wouldn't work with regular expression.
  19.  
  20. Well, it certainly isn't as concise as RE's, but the following matching procedure
  21. isn't too horrible, I think:
  22.  
  23.     procedure Vl(l)
  24.     static V
  25.     initial V := 'aeiou'
  26.  
  27.         suspend ( tab(upto(V)), move(1)||tab(any(l)) )
  28.  
  29.     end
  30.  
  31. And, if you wanted to parameterize it a bit more:
  32.  
  33.     # match pairs of a letter in a followed by a letter in b
  34.     procedure pair(a,b)    
  35.         suspend ( tab(upto(a)), move(1)||tab(any(b)) )
  36.     end
  37.  
  38. Both upto() and any() are efficient functions when given csets...
  39.  
  40. Here's a test driver for the second version:
  41.  
  42.     procedure main()
  43.  
  44.         every line := !&input do {
  45.             line ? every write( pair('aeiou', 'l') )
  46.             }
  47.  
  48.     end
  49.  
  50. --
  51. Steve Wampler - swampler@gemini.edu [Gemini 8m Telescopes Project (under AURA)]
  52. O Sibile, si ergo, fortibus es inero.
  53. Nobile, demis trux.  Demis phulla causan dux.
  54.